package zhr.chapter13.udpMultithreading;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class Send extends Thread{
    public void run(){
        try {
            DatagramSocket socket =new DatagramSocket(3000);
            Scanner sc=new Scanner(System.in);
            while (true){
                String str =sc.nextLine();
                if("quit".equals(str)) break;
                DatagramPacket packet=new DatagramPacket(str.getBytes(),str.getBytes().length,
                        InetAddress.getByName("172.28.37.153"),6666);
                socket.send(packet);
            }
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
